package com.microservice.salmon.weixin.utils;

import com.salmon.common.utils.DigestUtils;

import java.util.Arrays;

public class CheckUtils {

	private static final String token = "salmon";

	public static boolean checkSignature(String signature,String timestamp,String nonce){
		String[] arr = new String[]{token,timestamp,nonce};
		//排序
		Arrays.sort(arr);
		//生成字符串
		StringBuilder content = new StringBuilder();
		for(int i=0; i < arr.length; i++) {
			content.append(arr[i]);
		}
		//sha1加密
		String temp = DigestUtils.getSha1(content.toString());
		return temp.equals(signature);
	}

}
